package com.bwie.controller;

import com.bwie.pojo.TbAtta;
import com.bwie.pojo.TbProd;
import com.bwie.service.TbProdService;
import com.bwie.utils.Result;
import com.bwie.vo.ProdPageVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * description:
 *
 * @Author zhaohaoyang
 * @Create 2025/5/26 16:52
 * @Version 1.0
 */
@RestController
@RequestMapping("/shop/prod")
public class TbProdController {
    @Autowired
    TbProdService tbProdService;

    /**
     * 商品列表
     * @param prodPageVo
     * @return
     */
    @PostMapping("/getProdList")
    public Result getProdList(@RequestBody ProdPageVo prodPageVo){
        return tbProdService.getProdList(prodPageVo);
    }

    /**
     * 添加商品
     * @param tbProd
     * @return
     */
    @PostMapping("/addProd")
    public Result addProd(@RequestBody @Validated TbProd tbProd){
        return tbProdService.addProd(tbProd);
    }

    @PostMapping("/deleteAllProd")
    public Result deleteAllProd(@RequestBody List<TbProd> tbProdList){
        return tbProdService.deleteAllProd(tbProdList);
    }

    @PostMapping("/addProdAtta")
    public Result addProdAtta(@RequestBody TbAtta tbAtta){
        return tbProdService.addProdAtta(tbAtta);
    }

}
